function postJSON(url, data, callback, error) {
   $.ajax({ 
        url: url,
        type: 'post',
        contentType: 'application/json',
        data: JSON.stringify(data),
        dataType: 'json',
        success: function(data) {
            callback(data);
        },
        error: function(req, message, e) {
            console.log(message);

            if ( error ) {
                error(req, message, e);
            }
        }
    });
}

$(document).ready(function() {
    $('#btn-find-user').click(function(e) {
        e.preventDefault();

        var userId = $('#user-id').val();
        var user = {
            id: userId
        }

        postJSON('/user/find', {
                user: user
            },
            function(data) {
                $('#message-box').html(JSON.stringify(data));
            }
        );
    });
});
